﻿@{
     WebSecurity.RequireAuthenticatedUser();
    Layout = "~/_SiteLayout.cshtml";
    Page.Title = "REPORTS";
    Page.Region = RefDataManager.GetRegionLkUpVal();
    Page.IDType = RefDataManager.GetIDTypeLkUpVal();
    var pb = RefDataManager.GetPartnerBankLkUpVal();
    var sols = RefDataManager.GetSolicitorLkUpVal();
    var custStatus = RefDataManager.GetCustStatLkUpVal();
    var custClass = RefDataManager.GetCustClassLkUpVal();
    var campaign = RefDataManager.GetCampaignLkUpVal();
    var country = RefDataManager.GetCountryValues();
    var ccStatus = RefDataManager.GetCashCardStatLkUpVal();
    var ccDelStatus = RefDataManager.GetCardDelLkUpVal();
    var docStatus = RefDataManager.GetDocStatLkUpVal();
    var courierLkUp = CourierManager.GetCourierLkUpValues();
    var region = RefDataManager.GetRegionLkUpVal(); 
}

<style type="text/css">
/** { font-family: Verdana; font-size: 96%; }*/
label { width: 14em; float: left; }
label.error { float: none; color: red; padding-left: .5em; vertical-align: top; }
p { clear: both; }
.submit { margin-left: 12em; }
em { font-weight: bold; padding-right: 1em; vertical-align: top; }
.txt_style{
    width:200px;
}
</style>
<script>
    $(function(){
         //toggleFields(false);
        
        GetLookUp('#region','#country','country');     
        GetLookUp("#country","#state","state");
        
        $("#searchDate").datepicker({
                changeMonth:true,
                changeYear:true,
                showButtonPanel:true,
                dateformat:'dd/mm/yy',
                yearRange:'-100:+0',
                minDate: new Date(1930,1-1,1),
                maxDate: new Date(2012,12-1,31)
                });
    
        $("#reportType").change(function(){
            displayReportParams();
            
        });
        
        $("#search").click(function(){
            if(validateForm()){
               loadGrid();   
          }
        });
        
        document.onkeypress = processKey;
        
        showSpinner();
        
       
        setAutoComplete("#custName","#custId");
        setAutoComplete("#rBy","#rbyId");
       
        applyDatePicker("#from_ccsdate");
        applyDatePicker("#to_ccsdate");
        applyDatePicker("#from_delsdate");
        applyDatePicker("#to_delsdate");
        applyDatePicker("#from_deldate");
        applyDatePicker("#to_deldate");
        applyDatePicker("#from_expdate");
        applyDatePicker("#to_expdate");
        
         $("#clear").click(function(){
            clearForm("#reportForm");
        });
        
        
    });

    
function loadGrid(){
    
    var data = $("#reportForm").serialize();
    
    var dummy = new Date().getTime();
    $.get("/Reports/ReportGrid",data+"&dummy="+dummy,function(data){
        $("#results").empty();
        $("#results").html(data); 
    });
    
    //clear autocomplete fields
    $("#custId").val("");
    $("#rbyId").val("");
 
}    

function defaultDate(){
    return "01/01/1900";
}

function validateForm(){
     var ccsdateFrom = $("#from_ccsdate").val();
     var ccsdateTo = $("#to_ccsdate").val();
     var delsdateFrom = $("#from_delsdate").val();
     var delsdateTo = $("#to_delsdate").val();
     var deldateFrom = $("#from_deldate").val();
     var deldateTo = $("#to_deldate").val();
     var expdateFrom = $("#from_expdate").val();
     var expdateTo = $("#to_expdate").val();
     
     if(ccsdateFrom!=""){
        if(ccsdateTo==""){
             $("#to_ccsdate").focus();
             showErrorMessage("This field is required");
             errorCssOn("#to_ccsdate");
               return false;  
      }else{
         errorCssOff("#to_ccsdate");
        }
    }
    
    if(ccsdateTo!=""){
        if(ccsdateFrom==""){
             $("#from_ccsdate").focus();
             showErrorMessage("This field is required");
             errorCssOn("#from_ccsdate");
               return false;  
      }else{
         errorCssOff("#from_ccsdate");
        }
    }
    //------delsdate
     if(delsdateFrom!=""){
        if(delsdateTo==""){
             $("#to_delsdate").focus();
             showErrorMessage("This field is required");
             errorCssOn("#to_delsdate");
               return false;  
      }else{
         errorCssOff("#to_delsdate");
        }
    }
    
    if(delsdateTo!=""){
        if(delsdateFrom==""){
             $("#from_delsdate").focus();
             showErrorMessage("This field is required");
             errorCssOn("#from_delsdate");
               return false;  
      }else{
         errorCssOff("#from_delsdate");
        }
    }
    
    //--------Delivery date
    if(deldateFrom!=""){
        if(deldateTo==""){
             $("#to_deldate").focus();
             showErrorMessage("This field is required");
             errorCssOn("#to_deldate");
               return false;  
      }else{
         errorCssOff("#to_deldate");
        }
    }
    
    if(deldateTo!=""){
        if(deldateFrom==""){
             $("#from_deldate").focus();
             showErrorMessage("This field is required");
             errorCssOn("#from_deldate");
               return false;  
      }else{
         errorCssOff("#from_deldate");
        }
    }
    //------------Expiry date
    if(expdateFrom!=""){
        if(expdateTo==""){
             $("#to_expdate").focus();
             showErrorMessage("This field is required");
             errorCssOn("#to_expdate");
               return false;  
      }else{
         errorCssOff("#to_expdate");
        }
    }
    
    if(expdateTo!=""){
        if(expdateFrom==""){
             $("#from_expdate").focus();
             showErrorMessage("This field is required");
             errorCssOn("#from_expdate");
               return false;  
      }else{
         errorCssOff("#from_expdate");
        }
    }
    return true;
}

function processKey(e)
{
  if (null == e)
    e = window.event ;
  if (e.keyCode == 13)  {
     if(validateForm()){
          loadGrid();   
        }
  }
}
</script>
 <div id="message"></div>
<form id="reportForm" name="reportForm">
<div id="spinner" class="spinnerContent" style="display:none;border:1px solid black">
                    <img id="img-spinner" src="@Href("/images/ajax-loader.gif")" alt="Loading"/>
                    <p>Generating report please wait...</p>
                </div>
                <div id="spinnerBG"></div>    
 <input type="hidden" name="custId" id="custId"/>
 <input type="hidden" name="rbyId" id="rbyId"/>
 <input type="hidden" name="report" value="1"/>
    
    
<fieldset class="ui-widget ui-widget-content">
<legend>Cash Card Master List</legend>
  <div style="float:left;">  
  <div style="float:left;margin:0 .5em">
    <p>
    <label for="custName">CUSTOMER NAME:</label>
     <input id="custName" type="text" style="width:200px;" name="custName"/>
    </p>
    <p>
      <label for="custStatus">CUSTOMER STATUS:</label>
       
         <select name="cStatus" id="cStatus">
             <option id="default_cstatus" ></option>
            @foreach(var r in custStatus){
                    <option id="@r.RefDesc" value="@r.RefID">@r.RefDesc</option>
            }
        </select>   
    </p>
    <p>
        <label for="custClass">CUSTOMER CLASSIFICATION:</label>
         <select id="custClass" name="custClass" >
             <option id="default_cclass" ></option>
            @foreach(var r in custClass){
                    <option id="@r.RefDesc" value="@r.RefID" >@r.RefDesc</option>
            }
        </select>
    </p>
     
    <p><label for="solicitor">SOLICITOR:</label>
        
        <select name="solicitor" id="solicitor">
            <option id="default_solicitor"></option>
            @foreach(var r in sols){
                      <option id="@r.RefID" value="@r.RefID">@r.RefDesc</option>
              
            }
        </select>
        </p> 
        <p><label for="campaign">CAMPAIGN:</label>
        <select name="campaign" id="campaign">
            <option id="default_campaign"></option>
            @foreach(var r in campaign){
                   <option id="@r.RefID" value="@r.RefID">@r.RefDesc</option>
                
            }
        </select>
            </p>
      <p><label for="src_region">SOURCE REGION:</label>
       
        <select name="src_region" id="src_region">
        <option id="default_region" ></option>    
            @foreach(var r in region){
                   <option id="@r.RefDesc" value="@r.RefID">@r.RefDesc</option>  
            }
        </select>
            </p>
       <p><label for="region">REGION:</label>
       
        <select name="region" id="region">
        <option id="default_region" ></option>    
            @foreach(var r in region){
                   <option id="@r.RefDesc" value="@r.RefID">@r.RefDesc</option>  
            }
        </select>
            </p>
     <p><label for="country">COUNTRY:</label>
            <select name="country" id="country">
        </select>
        </p>   
    
    <p><label for="currMailState">STATE:</label>
        
        <select name="state" id="state">
            <option id="default_cstate"></option>
        </select>
        </p>
    </div>
    <div style="float:left">
     <p> <label for="refBy">REFERRED BY:</label>
         <input id="rBy"  type="text" style="width:200px;" name="rBy"/>
        </p>

    <p>
        <label for="ccno">CASH CARD NO.</label>
        <input type="text" style="width:200px;" name="ccno" id="ccno"/>
    </p>
     <p>
         <div class="validateCC">    
        <label for="ccstatus">CASH CARD STATUS:</label> <select name="ccstatus" id="ccstatus">
             <option id="default_ccstatus" ></option>
            @foreach(var cStatus in ccStatus){
                    <option id="@cStatus.RefDesc" value=@cStatus.RefID>@cStatus.RefDesc</option>
            }            
        </select>
        </div>    
            
        </p>
    <p>
        <label for="delStatus">CARD DELIVERY STATUS:</label> <select name="delStatus" id="delStatus">
             <option id="default_ccdelstatus" ></option>
            @foreach(var cDelStatus in ccDelStatus){
                    <option id="@cDelStatus.RefDesc" value=@cDelStatus.RefID>@cDelStatus.RefDesc</option>
            }            
        </select>
    </p>
    <p>
        <label for="docStatus">DOCUMENT STATUS:</label> <select name="docStatus" id="docStatus">
             <option id="default_docstatus" ></option>
            @foreach(var cDocStatus in docStatus){
                    <option id="@cDocStatus.RefDesc" value=@cDocStatus.RefID>@cDocStatus.RefDesc</option>
            }            
        </select>    
    </p>
    <p>
         <label for="partnerBank">PARTNER BANK:</label> <select name="pb" id="pb">
             <option id="default_pbank" ></option>
            @foreach(var cPartenerBnk in pb){
                    <option id="@cPartenerBnk.RefDesc" value=@cPartenerBnk.RefID>@cPartenerBnk.RefDesc</option>
            }            
        </select> 
    </p>
    <p>
         <label>CARD DELIVERY COURIER:</label>
          <select name="courier" id="courier">
            <option id="default_courier" value=""></option>
            @foreach(var cr in courierLkUp){
               <option id="@cr.Code"  value="@cr.Code">@cr.Name</option>  
            }
              
         </select>  
    </p>
    </div>
    </div> <!-- end of upper div-->
    
    <div style="float:left;margin:0 1em">
    <p>
        <label for="ccsdate">CASH CARD STATUS DATE:</label></p>
    <p><label for="from_ccsdate">FROM:</label></p>
         <p><input type="Text" style="width:100px;" name="from_ccsdate" value="" id="from_ccsdate"/>
        </p>
    <p>
        <label for="to_ccsdate">TO:</label></p>
    <p>    <input type="Text" style="width:100px;" name="to_ccsdate" value="" id="to_ccsdate"/>
    </p>
   
   
    <p> <label for="ccsdate">DELIVERY STATUS DATE:</label></p>
    <p>
        <label for="from_delsdate">FROM:</label></p>
       <p> <input type="Text" style="width:100px;" value="" name="from_delsdate" id="from_delsdate"/>
    </p>
    <p>     
          <label for="to_delsdate">TO:</label></p>
         <p><input type="Text" style="width:100px;" name="to_delsdate" value="" id="to_delsdate"/>
        
    </p>
   </div>
   <div style="float:left"> 
    <p>
        <label for="ccsdate">DELIVERY DATE:</label></p>
    <p>
         <label for="from_deldate">FROM:</label></p>
       <p> <input type="Text" style="width:100px;" name="from_deldate" value="" id="from_deldate"/>
    </p>
    <p>
          <label for="to_deldate">TO:</label></p>
       <p>  <input type="Text" style="width:100px;" name="to_deldate" value="" id="to_deldate"/>
        
    </p>
   
    <p>
        <label for="ccsdate">CASH CARD EXPIRY DATE:</label></p>
    <p>
         <label for="from_expdate">FROM:</label></p>
    <p>    <input type="Text" style="width:100px;" name="from_expdate" value="" id="from_expdate"/>
    </p>
    <p>
         <label for="to_expdate">TO:</label></p>
      <p>   <input type="Text" style="width:100px;" name="to_expdate" value="" id="to_expdate"/>
    </p>
    

</div><!--end of 2nd part div-->    
      <div id="buttons" style="clear:both">
        <input type="button" id="search"  value="search"/>
        <input type="button" id="clear" value="clear"/>
            
        
    </div>
  </fieldset>  
    <div id="results">
        
    </div>

</form>